<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>创建右键菜单</title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
</head>
<body>
<div style="width:520px;height:340px;border:1px solid gray" id="container"></div>
</body>
</html>
<script type="text/javascript">
var map = new BMap.Map("container"); 
var point = new BMap.Point(116.404, 39.915);
var menu = new BMap.ContextMenu();
var txtMenuItem = [
  {
   text:'添加起点',
   callback:function(point){
   		var marker = new BMap.Marker(point), px = map.pointToPixel(point);
    	map.addOverlay(marker);
   }
  }
 ];


 for(var i=0; i < txtMenuItem.length; i++){
  menu.addItem(new BMap.MenuItem(txtMenuItem[i].text,txtMenuItem[i].callback,100));
 }
 
 map.centerAndZoom(point,15);
 map.addContextMenu(menu);

</script>
